home *** CD-ROM | disk | FTP | other *** search
/ Mac Magazin/MacEasy 32 / Mac Magazin and MacEasy Magazine CD - Issue 32.iso / Online / map2html ƒ / map2html.pl < prev    next >
Perl Script  |  1997-02-26  |  1KB  |  58 lines

  1. #!/usr/bin/perl
  2.  
  3. #
  4. #    map2HTML 0.1b2 -- Parses an NCSA imagemap as created by webmap, and munges 
  5. #                      it into something suitable for cut-and-paste into an
  6. #                      HTML document.
  7. #
  8. #     (c) Wink, wink@nicom.com    2/26/97
  9. #
  10.  
  11. while (@ARGV) {
  12.     $input = shift;
  13.     
  14.     if ($input =~ /STDIN/) {    # We're using Alpha
  15.         $mapname = "•.map";
  16.         $imagename = "•";
  17.         $handle = "STDOUT";
  18.         
  19.     } else {    # Dropped files
  20.         $mapname = $input;
  21.         $mapname =~ s/.*://;
  22.         $imagename = "$mapname";
  23.         $imagename =~ s/.map$//;
  24.         
  25.         $handle = "FILE";
  26.         $file = $input . ".out";
  27.         open($handle, ">$file") or die "Can't create $file: $!\n";
  28.     }
  29.     
  30.     $in = "IN";
  31.     open(IN,"$input") or die "Can't open $input: $!\n";
  32.     
  33.     print $handle "<MAP NAME=\"$mapname\">\n";
  34.     
  35.     while (<$in>) {
  36.         
  37.         if (/^\w/) {
  38.             if (/^default/) {
  39.                 ($keyword, $default_url) = split;
  40.                 print $handle "<AREA SHAPE=\"default\" HREF=\"$default_url\">\n";
  41.                 
  42.             } else {
  43.                 s/(\d)\s(\d)/$1,$2/g;
  44.                 
  45.                 ($shape, $url, $coords) = split;            
  46.                 print $ handle "<AREA SHAPE=\"$shape\" COORDS=\"$coords\" HREF=\"$url\">\n";
  47.             }
  48.         }
  49.     }
  50.     
  51.     print $handle "</MAP>\n";
  52.     print $handle "<IMG USEMAP=\"\#$mapname\" SRC=\"$imagename\" BORDER=0>\n";
  53.     close($handle);
  54.     close($in);
  55. }
  56.  
  57.  
  58.